package com.it135.citytraffic.pojo.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Arrays;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * <p>
 * 路段拥堵情况时间表
 * </p>
 *
 * @author lh
 * @since 2024-07-10
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("road_time_statistic")
@NoArgsConstructor
@AllArgsConstructor
public class RoadTimeStatistic implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 路口在road_statistic中的id
     */
    private Long roadStatisticId;

    /**
     * 当前路况所在时间段[0,16] 对应[{6点到7点},{10点到11点}]到十一点
     */
    private String time;

    /**
     * 出现此种路况的次数
     */
    private Integer count;

    /**
     * 最后修改时间
     */
    private LocalDateTime updateTime;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;


    public  String getInfo(){
        StringBuilder result= new StringBuilder();
        Object[] array = Arrays.stream(this.time.split(",")).toArray();
        return result.append(array[0].toString()).append("点到")
                .append(array[1].toString()).append("点").toString();
    }

}
